package view.systemAdmiView;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import view.logOnView.LogOnFrm1;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JDesktopPane;
import java.awt.Toolkit;

public class SystemAdmiMainFrm extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					SystemAdmiMainFrm frame = new SystemAdmiMainFrm();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public SystemAdmiMainFrm() {
		setBackground(new Color(221, 160, 221));
		setIconImage(Toolkit.getDefaultToolkit().getImage(SystemAdmiMainFrm.class.getResource("/images/systemAdmi/系统管理员.png")));
		setTitle("系统管理员界面");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1339, 760);
		
		JDesktopPane table = new JDesktopPane();
		table.setBackground(new Color(224, 255, 255));
		
		
		JMenuBar menuBar = new JMenuBar();
		menuBar.setBackground(new Color(255, 218, 185));
		setJMenuBar(menuBar);
		
		JMenu userImfManageMenu = new JMenu("用户信息管理              ");
		userImfManageMenu.setIcon(new ImageIcon(SystemAdmiMainFrm.class.getResource("/images/systemAdmi/用户信息管理 (1).png")));
		userImfManageMenu.setFont(new Font("宋体", Font.BOLD, 28));
		userImfManageMenu.setBackground(Color.PINK);
		menuBar.add(userImfManageMenu);
		
		JMenuItem userImfMaintainMenuItem = new JMenuItem("用户信息维护");
		userImfMaintainMenuItem.setIcon(new ImageIcon(SystemAdmiMainFrm.class.getResource("/images/systemAdmi/用户信息维护.png")));
		userImfMaintainMenuItem.setFont(new Font("宋体", Font.BOLD, 25));
		userImfMaintainMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				UserImfManageInterFrm userImfManageInterFrm=new UserImfManageInterFrm();
				userImfManageInterFrm.setVisible(true);
				table.add(userImfManageInterFrm);
			}
		});
		userImfManageMenu.add(userImfMaintainMenuItem);
		
		JMenuItem userImfAddMenuItem = new JMenuItem("用户信息添加");
		userImfAddMenuItem.setIcon(new ImageIcon(SystemAdmiMainFrm.class.getResource("/images/systemAdmi/用户信息添加.png")));
		userImfAddMenuItem.setFont(new Font("宋体", Font.BOLD, 25));
		userImfAddMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				UserImfAddInterFrm userImfAddInterFrm=new UserImfAddInterFrm();
				userImfAddInterFrm.setVisible(true);
				table.add(userImfAddInterFrm);
			}
		});
		userImfManageMenu.add(userImfAddMenuItem);
		
		JMenu booKSearchMenu = new JMenu("有关图书查询          ");
		booKSearchMenu.setIcon(new ImageIcon(SystemAdmiMainFrm.class.getResource("/images/systemAdmi/图书查询.png")));
		booKSearchMenu.setFont(new Font("宋体", Font.BOLD, 28));
		menuBar.add(booKSearchMenu);
		
		JMenuItem bookSearchMenuItem = new JMenuItem("图书查询");
		bookSearchMenuItem.setIcon(new ImageIcon(SystemAdmiMainFrm.class.getResource("/images/bookAdmi/图书查询_intouch.png")));
		bookSearchMenuItem.setFont(new Font("宋体", Font.BOLD, 25));
		bookSearchMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				BookSearchInterFrm bookSearchInterFrm=new BookSearchInterFrm();
				bookSearchInterFrm.setVisible(true);
				table.add(bookSearchInterFrm);
			}
		});
		booKSearchMenu.add(bookSearchMenuItem);
		
		JMenu logOffNewMenu = new JMenu("安全退出");
		logOffNewMenu.setIcon(new ImageIcon(SystemAdmiMainFrm.class.getResource("/images/退出登录 (1).png")));
		logOffNewMenu.setFont(new Font("宋体", Font.BOLD, 28));
		menuBar.add(logOffNewMenu);
		
		JMenuItem logOffMenuItem = new JMenuItem("退出登录");
		logOffMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				int result=JOptionPane.showConfirmDialog(null, "是否退出登录");
//				System.out.println(result);    可以利用输出进行断点调试
				if(result==0) {
					dispose();
					LogOnFrm1 logOnFrm=new LogOnFrm1();
					logOnFrm.setVisible(true);
				}
			}
		});
		logOffMenuItem.setIcon(new ImageIcon(SystemAdmiMainFrm.class.getResource("/images/bookAdmi/退出登录.png")));
		logOffMenuItem.setFont(new Font("宋体", Font.BOLD, 25));
		logOffNewMenu.add(logOffMenuItem);
		
		JMenuItem logOffSystemMenuItem = new JMenuItem("退出系统");
		logOffSystemMenuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				int result=JOptionPane.showConfirmDialog(null, "是否退出登录");
//				System.out.println(result);    可以利用输出进行断点调试
				if(result==0) {
					dispose();
					LogOnFrm1 logOnFrm=new LogOnFrm1();
					logOnFrm.setVisible(true);
				}
			}
		});
		logOffSystemMenuItem.setIcon(new ImageIcon(SystemAdmiMainFrm.class.getResource("/images/bookAdmi/退出登录.png")));
		logOffSystemMenuItem.setFont(new Font("宋体", Font.BOLD, 25));
		logOffNewMenu.add(logOffSystemMenuItem);
		contentPane = new JPanel();
		contentPane.setBackground(new Color(255, 255, 255));
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new BorderLayout(0, 0));
		
		contentPane.add(table, BorderLayout.CENTER);
		
		//设置JFrame最大化
		this.setExtendedState(JFrame.MAXIMIZED_BOTH);
	}
}
